package com.wangxin.study8.comparators;

import com.wangxin.study8.constructor.Person;

import java.util.Comparator;

/**
 * @ClassName ComparatorsMain
 * @Description TODO
 * @Author jojo.wang
 * @Date 2019-04-25 15:38
 * @Version 1.0
 **/
public class ComparatorsMain {
    public static void main(String[] args) {
        Comparator<Person> comparator = (p1, p2)->p1.getStr1().compareTo(p2.getStr1());
        Person a1 = new Person("jojo","jojo");
        Person a2 = new Person("xin","xin");
        System.out.println(comparator.compare(a1,a2));
        System.out.println(comparator.reversed().compare(a1,a2));
    }
}
